function animate(el, target) {

    if(el.interval){ //防止给元素重复设定定时器
        clearInterval(el.interval)
    }

    //获取初始的位置 leader
    let leader = el.offsetLeft;
    let step = 20;
    step = leader < target ? step : -step
    // console.log(step)
    //设定定时器
    el.interval = setInterval(() => {
        if (Math.abs(leader - target) >= Math.abs(step)) {
            leader += step
            el.style.left = leader + 'px'
        } else {
            //剩下的距离不满足一个step
            //手动将元素放到目标位置 并且清除定时器
            el.style.left = target + "px";
            clearInterval(el.interval)
        }
    }, 15) //大概60帧

}